$.fn.hfCalendar = function (option,callBackFn) {
    var month_olympic = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var month_normal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var month_name = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
//获取某年某月第一天是星期几
    function dayStart(month, year) {
        var tmpDate = new Date(year, month, 1);
        return (tmpDate.getDay());
    }

//计算某年是不是闰年，通过求年份除以4的余数即可
    function daysMonth(month, year) {
        var tmp = year % 4;
        if (tmp == 0) {
            return (month_olympic[month]);
        } else {
            return (month_normal[month]);
        }
    }

    var my_date = new Date();
    var my_year = my_date.getFullYear();
    var my_month = my_date.getMonth();
    var my_day = my_date.getDate();
    var holder  =  $(this),
        options = {
            pre: option.pre || '.month-pre',
            next: option.next || ".month-next",
            data:option.data
        };

    var pre = $(option.pre);
    var next = $(option.next);

    pre.click(function () {
        renderCalendar(options.data)
    });
    next.click(function () {
        renderCalendar(options.data)
    });

    function renderCalendar(obj) {


        //alert(111)
        var str = "";
        var totalDay = daysMonth(my_month, my_year); //获取该月总天数
        var firstDay = dayStart(my_month, my_year); //获取该月第一天是星期几
        var myclass;
        for (var k = 1; k < firstDay; k++) {
            str += "<li></li>"; //为起始日之前的日期创建空白节点
        }
        for (var i = 1; i <= totalDay; i++) {
            if ((i < my_day && my_year == my_date.getFullYear() && my_month == my_date.getMonth()) || my_year < my_date.getFullYear() || (my_year == my_date.getFullYear() && my_month < my_date.getMonth())) {
                if (i<=obj.taskDetail.length) {
                    if(obj.taskDetail[i-1].task){
                        myclass = " class='lightgrey has'"
                    }else {
                        myclass = " class='lightgrey'"; //当该日期在今天之前时，以浅灰色字体显示
                    }
                }else {
                    myclass = " class='lightgrey'"; //当该日期在今天之前时，以浅灰色字体显示
                }
            } else if (i == my_day && my_year == my_date.getFullYear() && my_month == my_date.getMonth()) {
                myclass = " class='green greenbox'"; //当该日期是当天时，
            } else {
                myclass = " class='darkgrey'"; //当该日期在今后之后时，以深灰字体显示
            }
            str += "<li" + myclass + ">" + i + "</li>"; //创建日期节点

        }

        holder.html(str); //设置日期显示

        holder.find('li').click(function () {
            if($(this).attr("class")){
                $(this).addClass('active').siblings().removeClass('active');
            }
            if(callBackFn) callBackFn()

        })

    }


    renderCalendar(options.data)

};








